<?php
declare (strict_types=1);

namespace app\listener\order;

use app\service\core\card\CoreGoodsSaleNumService;
use app\service\core\card\CoreGoodsStockService;
use app\dict\order\OrderDict;
use app\api\model\order\OrderGoods;
use app\service\core\notice\NoticeService;
use app\service\core\order\CoreOrderLogService;
use think\facade\Log;

class AfterShopOrderRefuse
{

    public function handle($data)
    {
        Log::write('订单AfterShopOrderRefuse' . json_encode($data));
        try {
            $order_data = $data['order_data'];
            //日志
            $main_type = $data['main_type'];
            $main_id = $data['main_id'];
            (new CoreOrderLogService())->add([
                'order_id' => $order_data['order_id'],
                'status' => OrderDict::WAIT_RETURN,
                'main_type' => $main_type,
                'main_id' => $main_id,
                'type' => OrderDict::ORDER_REFUSE_ACTION,
                'content' => ''
            ]);




            //消息发送
            //消息发送
            (new NoticeService())->send('shop_order_refuse', ['order_id' => $order_data['order_id']]);



        } catch ( \Exception $e ) {
            Log::write('订单AfterShopOrderRefuse失败' . $e->getMessage() . $e->getFile() . $e->getLine());
        }
    }
}
